
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户按下键盘，显示keyCode</title>
<style>
body{
	text-align:center;
	font:30px/1.5 \5fae\8f6f\96c5\9ed1, arial;	
}
pre{color:green;padding:10px 15px;background:#f0f0f0;border:1px dotted #333;font:12px/1.5 Courier New;text-align:left;}
span{color:#999;}
</style>
<script type="text/javascript">
window.onload = function ()
{
	var oP = document.getElementsByTagName("p")[0];	
	document.onkeydown = function (event)
	{
		var event = event || window.event;
		oP.innerHTML = event.keyCode;
		return false
	}
}
</script>
</head>
<body>
<pre>
&lt;script type="text/javascript"&gt;
window.onload = function ()
{
	var oP = document.getElementsByTagName("p")[0];	
	document.onkeydown = function (event)
	{
		var event = event || window.event;
		oP.innerHTML = event.keyCode;
		return false
	}
}
&lt;/script&gt;
</pre>
<p>这里将显示您按下键的 keyCode</p>
</body>
</html>
